This document has code embedded throughout. In the next section we will create a visualization using the already loaded dataset cryptodata:
datatable(eth_data, rownames = FALSE,
options(list(lengthMenu = c(4, 5, 6))))
This document has code embedded throughout. In the next section we will create a visualization using the already loaded dataset cryptodata:
datatable(eth_data, rownames = FALSE,
options(list(lengthMenu = c(4, 5, 6))))
import pandas as pd # Create the Python object from R df = r.cryptodata # Show the new Python dataframe df
## pair symbol ask_1_price date_time_utc ## 0 BTCUSD BTC 18321.620 2020-12-09 00:00:01 ## 1 ETHUSD ETH 554.995 2020-12-09 00:00:01 ## 2 BTCUSD BTC 18181.050 2020-12-09 01:00:00 ## 3 ETHUSD ETH 550.456 2020-12-09 01:00:01 ## 4 BTCUSD BTC 18220.980 2020-12-09 02:00:00 ## ... ... ... ... ... ## 4929 BTCUSD BTC 11847.080 2020-08-10 21:03:49 ## 4930 BTCUSD BTC 11819.920 2020-08-10 22:03:49 ## 4931 BTCUSD BTC 11804.900 2020-08-10 23:03:54 ## 4932 BTCUSD BTC 10686.880 NaT ## 4933 ETHUSD ETH 357.844 NaT ## ## [4934 rows x 4 columns]
Press on w on your keyboard to make the presentation wider. Press f to fullscreen.
import numpy as np
# Create a new field based on the ask_1_price value:
df['price_percentile'] = np.where(df['ask_1_price'] > np.percentile(df['ask_1_price'], 50),
'upper 50th percentile of prices',
'lower 50th percentile of prices')
# Show modified dataframe:
df[['symbol', 'ask_1_price', 'price_percentile']]
## symbol ask_1_price price_percentile ## 0 BTC 18321.620 upper 50th percentile of prices ## 1 ETH 554.995 lower 50th percentile of prices ## 2 BTC 18181.050 upper 50th percentile of prices ## 3 ETH 550.456 lower 50th percentile of prices ## 4 BTC 18220.980 upper 50th percentile of prices ## ... ... ... ... ## 4929 BTC 11847.080 upper 50th percentile of prices ## 4930 BTC 11819.920 upper 50th percentile of prices ## 4931 BTC 11804.900 upper 50th percentile of prices ## 4932 BTC 10686.880 upper 50th percentile of prices ## 4933 ETH 357.844 lower 50th percentile of prices ## ## [4934 rows x 3 columns]
knitr::include_url("https://r-markdown-gallery.org")